﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using GurLoader;
using GurLoader.Service;
using GurLoader.Service.ImgurTaskBuilder;
using Moq;
using NUnit.Framework;

namespace GurLoaderWPF.Test
{
    [TestFixture]
    public class CommandPreparedEventArgsTests
    {
        [Test]
        public void CreateInstanceTest()
        {
            Task<ImgurProcessResult> task = new Task<ImgurProcessResult>(() =>
            {
                return null;
            });

            CancellationTokenSource ctSource = new CancellationTokenSource();
            Mock<Progress<IDelegatingCommandProgress>> mockProgress = new Mock<Progress<IDelegatingCommandProgress>>();

            var args = new CommandPreparedEventArgs(task, ctSource, mockProgress.Object);

            Assert.IsNotNull(args);
        }

        [Test]
        [ExpectedException(typeof(ArgumentNullException))]
        public void CreateInstanceNullTaskTest()
        {
            Task<ImgurProcessResult> task = null;
            CancellationTokenSource ctSource = new CancellationTokenSource();
            Mock<Progress<IDelegatingCommandProgress>> mockProgress = new Mock<Progress<IDelegatingCommandProgress>>();

            var args = new CommandPreparedEventArgs(task, ctSource, mockProgress.Object);
        }

        [Test]
        [ExpectedException(typeof(ArgumentNullException))]
        public void CreateInstanceNullCancellationTokenSourceTest()
        {
            Task<ImgurProcessResult> task = new Task<ImgurProcessResult>(() =>
            {
                return null;
            });

            CancellationTokenSource ctSource = null;
            Mock<Progress<IDelegatingCommandProgress>> mockProgress = new Mock<Progress<IDelegatingCommandProgress>>();

            var args = new CommandPreparedEventArgs(task, ctSource, mockProgress.Object);
        }

        [Test]
        [ExpectedException(typeof(ArgumentNullException))]
        public void CreateInstanceNullProgressTest()
        {
            Task<ImgurProcessResult> task = new Task<ImgurProcessResult>(() =>
            {
                return null;
            });

            CancellationTokenSource ctSource = new CancellationTokenSource();

            var args = new CommandPreparedEventArgs(task, ctSource, null);
        }
    }
}
